import {createRouter, createWebHistory} from 'vue-router'
import Index from '../views/Index.vue'
import BusinessList from '../views/BusinessList.vue'
import BusinessInfo from "@/views/BusinessInfo";
import Login from "@/views/Login";
import Orders from "@/views/Orders";
import UserAddress from "@/views/UserAddress";
import Payment from "@/views/Payment";
import OrderList from "@/views/OrderList";
import AddUserAddress from "@/views/AddUserAddress";
import EditUserAddress from "@/views/EditUserAddress";
import Register from "@/views/Register";
import Search from "@/views/Search";
import SearchList from "@/views/SearchList";
import HomePage from "@/views/HomePage";
import Wallet from "@/views/Wallet";
import Recharge from "@/views/Recharge";
import WalletDetail from "@/views/WalletDetail";
import Withdraw from "@/views/Withdraw";
import PointLog from "@/views/PointLog";
import PointUse from "@/views/PointUse";
import Error403 from "@/components/Error403";

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Index
    },
    {
        path: '/index',
        name: 'IndexPage',
        component: Index
    },
    {
        path: '/businessList',
        name: 'BusinessList',
        component: BusinessList
    },
    {
        path: '/businessInfo',
        name: 'BusinessInfo',
        component: BusinessInfo
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/orders',
        name: 'Orders',
        component: Orders
    },
    {
        path: '/userAddress',
        name: 'UserAddress',
        component: UserAddress
    },
    {
        path: '/payment',
        name: 'Payment',
        component: Payment
    },
    {
        path: '/orderList',
        name: 'OrderList',
        component: OrderList
    },
    {
        path: '/addUserAddress',
        name: 'AddUserAddress',
        component: AddUserAddress
    },
    {
        path: '/editUserAddress',
        name: 'EditUserAddress',
        component: EditUserAddress
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },
    {
        path: '/search',
        name: 'Search',
        component: Search
    },
    {
        path: '/searchList',
        name: 'SearchList',
        component: SearchList
    },
    {
        path: '/homePage',
        name: 'HomePage',
        component: HomePage
    },
    {
        path: '/wallet',
        name: 'Wallet',
        component: Wallet
    },
    {
        path: '/recharge',
        name: 'Recharge',
        component: Recharge
    },
    {
        path: '/walletDetail',
        name: 'WalletDetail',
        component: WalletDetail
    },
    {
        path: '/withdraw',
        name: 'Withdraw',
        component: Withdraw
    },
    {
        path: '/pointLog',
        name: 'PointLog',
        component: PointLog
    },
    {
        path: '/pointUse',
        name: 'PointUse',
        component: PointUse
    },
    {
        path: '/error403',
        name: 'Error403',
        component: Error403
    }
]

//解决重复路由报异常问题
// const originalPush = VueRouter.prototype.push;
// VueRouter.prototype.push = function push(location) {
//     return originalPush.call(this, location).catch(err => err)
// }

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})

export default router
